import { http } from "@/utils/http";
import { baseUrlApi } from "@/api/utils";
import { message } from "@/utils/message";
type Result = {
	current_page : number;
	result ?: any;
	per_page ?: number;
	total ?: number;
	data ?: any;
};
type ResultDelete = {
	code : number;
	msg : string;
};
type ResultCreate = {
	code : number;
	msg : string;
};
type Show = {
	code : number;
	msg : string;
	result ?: any;
};

/** 出库订单列表 */
export const getDeliveryOrderListApi = (params ?: object) => {
	return http.request<Result>("get", "/deliveryOrder/list", {
		params
	});
};
/** 出库订单添加*/
export const createDeliveryOrderApi = (data ?: object) => {
	return http.request<ResultCreate>("post", "/deliveryOrder/store", {
		data
	})
	.catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 出库订单修改 */
export const updateDeliveryOrderApi = (data ?: object) => {
	return http.request<ResultCreate>("put", "/deliveryOrder/update", {
		data
	})
	.catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 出库订单删除 */
export const delDeliveryOrderApi = (params ?: object) => {
	return http.request<ResultDelete>("delete", "/deliveryOrder/delete", {
		params
	})
	.catch(error => {
		message(error.response.data.msg ?? "操作失败,请联系管理员", {
			type: "error"
		});
	});
};
/** 出库订单详情 */
export const getDeliveryOrderShowApi = (params ?: object) => {
	return http.request<Show>("get", "/deliveryOrder/show", {
		params
	});
};